<template>
	<div class="mainCont">
		<div class="leftCont">
			<ul class="snav">
				<!-- {{permissions}} -->
				<li v-if="permissions.indexOf(8)  != -1">
					<router-link to="/list" v-if="$route.name=='list'" @click.native="flushCom"
						:class="$route.name=='list'?'active':''">服务台</router-link>
					<router-link to="/list" v-else :class="$route.name=='list'?'active':''">服务台</router-link>
				</li>
				<li v-if="permissions.indexOf(11)  != -1">
					<router-link to="/workorder" v-if="$route.name=='workorder'" @click.native="flushCom"
						:class="$route.name=='workorder'?'active':''">我的工单</router-link>
					<router-link to="/workorder" v-else :class="$route.name=='workorder'?'active':''">我的工单</router-link>
				</li>
				<li v-if="permissions.indexOf(101)  != -1">
					<router-link to="/callLog" v-if="$route.name=='callLog'" @click.native="flushCom"
						:class="$route.name=='callLog'?'active':''">通话记录</router-link>
					<router-link to="/callLog" v-else :class="$route.name=='callLog'?'active':''">通话记录</router-link>
				</li>
				<li v-if="permissions.indexOf(14)  != -1">
					<router-link to="/searchorder" v-if="$route.name=='searchorder'" @click.native="flushCom"
						:class="$route.name=='searchorder'?'active':''">工单查询</router-link>
					<router-link to="/searchorder" v-else :class="$route.name=='searchorder'?'active':''">工单查询
					</router-link>
				</li>
				<li v-if="permissions.indexOf(14)  != -1">
					<router-link to="/workapprove" v-if="$route.name=='workapprove'" @click.native="flushCom"
						:class="$route.name=='workapprove'?'active':''">工单审批</router-link>
					<router-link to="/workapprove" v-else :class="$route.name=='workapprove'?'active':''">工单审批
					</router-link>
				</li>
				<li v-if="permissions.indexOf(42)  != -1">
					<router-link to="/automatic" v-if="$route.name=='automatic'" @click.native="flushCom"
						:class="$route.name=='automatic'?'active':''">自动派单</router-link>
					<router-link to="/automatic" v-else :class="$route.name=='automatic'?'active':''">自动派单
					</router-link>
				</li>
				<li v-if="permissions.indexOf(83)  != -1">
					<a href="#" @click="down2=!down2">统计分析 <span class="iconfont icon-up"
							:style="down2?'transform: rotateZ(180deg);':'transform: rotateZ(0deg);'"></span></a>
					<div class="down" v-if="down2">
						<router-link to="/statistical_engineer" v-if="$route.name=='statistical_engineer'"
							@click.native="flushCom" :class="$route.name=='statistical_engineer'?'active':''">工程师统计分析
						</router-link>
						<router-link to="/statistical_engineer" v-else
							:class="$route.name=='statistical_engineer'?'active':''">工程师统计分析
						</router-link>

						<router-link to="/statistical_group" v-if="$route.name=='statistical_group'"
							@click.native="flushCom" :class="$route.name=='statistical_group'?'active':''">按小组统计
						</router-link>
						<router-link to="/statistical_group" v-else
							:class="$route.name=='statistical_group'?'active':''">按小组统计
						</router-link>

						<router-link to="/statistical_department" v-if="$route.name=='statistical_department'"
							@click.native="flushCom" :class="$route.name=='statistical_department'?'active':''">按科室统计
						</router-link>
						<router-link to="/statistical_department" v-else
							:class="$route.name=='statistical_department'?'active':''">按科室统计
						</router-link>

						<router-link to="/statistical_faultType" v-if="$route.name=='statistical_faultType'"
							@click.native="flushCom" :class="$route.name=='statistical_faultType'?'active':''">按故障分类统计
						</router-link>
						<router-link to="/statistical_faultType" v-else
							:class="$route.name=='statistical_faultType'?'active':''">按故障分类统计
						</router-link>

						<router-link to="/statistical_faultCause" v-if="$route.name=='statistical_faultCause'"
							@click.native="flushCom" :class="$route.name=='statistical_faultCause'?'active':''">按故障原因统计
						</router-link>
						<router-link to="/statistical_faultCause" v-else
							:class="$route.name=='statistical_faultCause'?'active':''">按故障原因统计
						</router-link>

						<router-link to="/statistical_score" v-if="$route.name=='statistical_score'"
							@click.native="flushCom" :class="$route.name=='statistical_score'?'active':''">按绩效统计
						</router-link>
						<router-link to="/statistical_score" v-else
							:class="$route.name=='statistical_score'?'active':''">按绩效统计
						</router-link>
					</div>
				</li>
				<li v-if="permissions.indexOf(42)  != -1">
					<a href="#" @click="down3=!down3">设置<span class="iconfont icon-up"
							:style="down3?'transform: rotateZ(180deg);':'transform: rotateZ(0deg);'"></span> </a>
					<div class="down" v-if="down3">
						<router-link to="/faultType" v-if="$route.name=='faultType'" @click.native="flushCom"
							:class="$route.name=='faultType'?'active':''">故障类型</router-link>
						<router-link to="/faultType" v-else :class="$route.name=='faultType'?'active':''">故障类型
						</router-link>

						<router-link to="/faultCause" v-if="$route.name=='faultCause'" @click.native="flushCom"
							:class="$route.name=='faultCause'?'active':''">故障原因</router-link>
						<router-link to="/faultCause" v-else :class="$route.name=='faultCause'?'active':''">故障原因
						</router-link>

						<router-link to="/watchmanScheduling" v-if="$route.name=='watchmanScheduling'"
							@click.native="flushCom" :class="$route.name=='watchmanScheduling'?'active':''">工单排班
						</router-link>
						<router-link to="/watchmanScheduling" v-else
							:class="$route.name=='watchmanScheduling'?'active':''">工单排班
						</router-link>

						<router-link to="/parameter" v-if="$route.name=='parameter'" @click.native="flushCom"
							:class="$route.name=='parameter'?'active':''">参数设置
						</router-link>
						<router-link to="/parameter" v-else :class="$route.name=='parameter'?'active':''">参数设置
						</router-link>

						<router-link to="/phrase" v-if="$route.name=='phrase'" @click.native="flushCom"
							:class="$route.name=='phrase'?'active':''">常用语管理</router-link>
						<router-link to="/phrase" v-else :class="$route.name=='phrase'?'active':''">常用语管理</router-link>


						<router-link to="/scheduling" v-if="$route.name=='scheduling'" @click.native="flushCom"
							:class="$route.name=='scheduling'?'active':''">值班电话排班</router-link>
						<router-link to="/scheduling" v-else :class="$route.name=='scheduling'?'active':''">值班电话排班
						</router-link>

						<router-link to="/timeRange" v-if="$route.name=='timeRange'" @click.native="flushCom"
							:class="$route.name=='timeRange'?'active':''">扫码报修时间段</router-link>
						<router-link to="/timeRange" v-else :class="$route.name=='timeRange'?'active':''">扫码报修时间段
						</router-link>


						<router-link to="/workTimeRange" v-if="$route.name=='workTimeRange'" @click.native="flushCom"
							:class="$route.name=='workTimeRange'?'active':''">自动派单时间段</router-link>
						<router-link to="/workTimeRange" v-else :class="$route.name=='workTimeRange'?'active':''">
							自动派单时间段
						</router-link>

						<router-link to="/ipset" v-if="$route.name=='ipset'" @click.native="flushCom"
							:class="$route.name=='ipset'?'active':''">网段负责人设置</router-link>
						<router-link to="/ipset" v-else :class="$route.name=='ipset'?'active':''">
							网段负责人设置
						</router-link>

					</div>
				</li>
			</ul>

		</div>

		<div class="rightCont">
			<router-view ref="child">
			</router-view>
		</div>

	</div>
</template>
<script type="text/babel">
	import Vue from 'vue'
	export default {
		name: "",
		data() {
			return {
				down1: true,
				down2: true,
				down3: true,
				permissions:[]
			};
		},
		mounted() {
			 var that = this
			// console.log(123123)
			var t = setInterval(function(){
				if(sessionStorage.getItem('permissions')){
					that.getprower()
					// that.permissions = that.$permissions
					clearInterval(t)
				}
			},500)
		},
		methods: {
			getlist(){
				this.$refs.child.getlist()
			},
			getprower(){
				
				var that = this
			
				var url = ''
								
										that.permissions = that.$permissions
										
									if(((that.$route.name =='parameter'||that.$route.name =='watchmanScheduling'||that.$route.name =='workTimeRange'||that.$route.name =='faultType'||that.$route.name =='faultCause'||that.$route.name =='phrase'||that.$route.name =='timeRange'||that.$route.name =='scheduling') && that.permissions.indexOf(42) != -1) ||(that.$route.name =='statistical_engineer'||that.$route.name =='statistical_group'||that.$route.name =='statistical_department'||that.$route.name =='statistical_faultType'||that.$route.name =='statistical_faultCause') && that.permissions.indexOf(83) != -1){
										
									}else{
										sessionStorage.setItem("rou",1)
										that.$forceUpdate()
										// alert(that.$route.name)
										if(that.permissions.indexOf(8) != -1){
											url = '/list'
										}else if(that.permissions.indexOf(11) != -1){
											url = '/workorder'
										}else if(that.permissions.indexOf(101) != -1){
											url = '/callLog'
										}else if(that.permissions.indexOf(14) != -1){
											url = '/searchorder'
										}else if(that.permissions.indexOf(83) != -1){
											url = '/statistical_engineer'
										}else if(that.permissions.indexOf(42) != -1){
											url = '/automatic'
										}
									if(url == '/repositorySearch'){
										if(that.permissions.indexOf(56)  != -1 || that.permissions.indexOf(58)  != -1 || that.permissions.indexOf(60)  != -1){
											sessionStorage.setItem("rou",7)
											
											if(that.permissions.indexOf(56) != -1){
												url = '/repositorySearch'
											}else if(that.permissions.indexOf(58) != -1){
												url = '/myRepository'
											}else if(that.permissions.indexOf(60) != -1){
												url = '/repositoryAudit'
											}
										}else{
											
											if(that.permissions.indexOf(70) != -1){
												url = '/department'
											}else if(that.permissions.indexOf(73) != -1){
												url = '/userlist'
											}else if(that.permissions.indexOf(76) != -1){
												url = '/group'
											}else if(that.permissions.indexOf(79) != -1){
												url = '/engineer'
											}else if(that.permissions.indexOf(93) != -1){
												url = '/permissions'
											}else{
												url = '/log'
												// console.log('log222')
												sessionStorage.setItem("rou",8)
												
											}
											
										}
										
									}
									
									}
									that.$router.push(url);
								that.$forceUpdate()
							that.showloading = false
			},
			flushCom:function(){
		// 　　　　　　this.$router.go(0);
		　　}
		},

		computed: {},
	};
</script>
<style lang='less' scoped>
	li {
		background: #fff;
		position: relative;
		z-index: 2;

	}

	.rightCont {
		position: relative;
	}

	.icon-up {
		transition: all .3s;
	}

	.down {
		transition: all .3s;
	}
</style>
